package com.example.androidproject.movie.adapter;

import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.util.Log;
import android.view.ViewGroup;
import android.widget.ImageView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.RecyclerView;

import com.bumptech.glide.Glide;
import com.bumptech.glide.load.resource.bitmap.RoundedCorners;
import com.bumptech.glide.request.RequestOptions;
import com.bumptech.glide.request.target.CustomTarget;
import com.bumptech.glide.request.transition.Transition;
import com.example.androidproject.movie.bean.ResultBeanData;
import com.example.androidproject.utils.ScreenUtils;
import com.example.androidproject.utils.TransformtionUtils;
import com.youth.banner.adapter.BannerAdapter;

import java.util.List;

public class BannerImageAdapter1 extends BannerAdapter<String, BannerImageAdapter1.BannerViewHolder> {

    private static final String TAG = "GGSTDUY";
    private final Context mContext;

    public BannerImageAdapter1(List<String> datas, Context context) {
        super(datas);
        this.mContext = context;
    }

    @Override
    public BannerImageAdapter1.BannerViewHolder onCreateHolder(ViewGroup parent, int viewType) {
        ImageView imageView = new ImageView(parent.getContext());
        //注意，必须设置为match_parent，这个是viewpager2强制要求的
        imageView.setLayoutParams(new ViewGroup.LayoutParams(
                ViewGroup.LayoutParams.MATCH_PARENT,
                ViewGroup.LayoutParams.MATCH_PARENT));

        imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
        return new BannerViewHolder(imageView);
    }

    @Override
    public void onBindView(BannerImageAdapter1.BannerViewHolder holder, String data, int position, int size) {
        Glide.with(holder.itemView)
                .asBitmap()
                .load(data)
                .into(holder.imageView);

    }

    public static class BannerViewHolder extends RecyclerView.ViewHolder {
        private final ImageView imageView;

        public BannerViewHolder(@NonNull ImageView view) {
            super(view);
            this.imageView = view;
        }
    }
}
